package com.nchu.romantic.surprise.action;

import com.nchu.romantic.surprise.model.BaseEnity;
import com.nchu.romantic.surprise.service.BaseService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author fujianjian
 * @project react-learning
 * @date 2018/10/21 下午1:40
 */
public abstract class BaseAction<T extends BaseEnity> {

    private Logger log = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private BaseService<T> baseService;


    /*@PostMapping("edit")
    public ActionResp<T> editEntity(ActionReq<T> req) {
        log.info("edit entity param: {}", req);
        T entity = req.getParam();
        Optional<Integer> idOpt = Optional.ofNullable(entity.getId());
        idOpt.map(id -> baseService.update(entity)).orElseGet((Supplier<? extends T>) baseService.create(entity));
        this.baseService.create(req.getParam());
        return (ActionResp<T>) ActionResp.builder().code(200).msg("success").data(entity).build();
    }*/
}
